package com.zjnx.train.tcp;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;

import net.sf.json.JSONObject;

public class Cmd2Processer implements CmdProcesser {
	public static Cmd2Processer instance;

	static {
		instance = new Cmd2Processer();
	}

	private Cmd2Processer() {
	}

	public void process(Socket client, JSONObject jsmsg) {
		PrintWriter out = null;
		try {
			out = new PrintWriter(client.getOutputStream());

			JSONObject jb = new JSONObject();
			String cmdmsg = "roger that, i am 2";
			jb.put("cmd", cmdmsg);
			out.println(jb.toString());
			out.flush();
			System.out.println("send cmd: " + cmdmsg);

			out.println("bye");
			out.flush();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			if (out != null)
				out.close();
		}

	}

}
